﻿using System.Configuration;
using System.Web.UI.WebControls;
using Controllers;

namespace Web
{
    public partial class RoleMenu : System.Web.UI.Page
    {
        protected void Page_Load(object sender, System.EventArgs e)
        {
            ApolloOaDataContext ctx = new ApolloOaDataContext(ConfigurationManager.ConnectionStrings["SqlConnectionString"].ConnectionString);
            int roleId = int.Parse(Request.QueryString["roleId"]);

            string strSql = @"SELECT * FROM Menus where IsDefault=0 and Id not in(select MenuId from RoleMenus where RoleId={0});";
            var list = ctx.ExecuteQuery<Menus>(strSql, roleId);
            rptMenuList.DataSource = list;
            rptMenuList.DataBind();
            //主送人员
            strSql = @"SELECT * FROM Menus where IsDefault=0 and Id in(select MenuId from RoleMenus where RoleId={0});";
            var list2 = ctx.ExecuteQuery<Menus>(strSql, roleId);
            rptChoosedMenuList.DataSource = list2;
            rptChoosedMenuList.DataBind();
        }
    }
}